import { BasicColumn, FormSchema } from '/@/components/Table';
export const columns: BasicColumn[] = [
  {
    title: '数据源名称',
    dataIndex: 'name',
    width: 120,
    align: 'left',
  },
  {
    title: '数据库类型',
    dataIndex: 'dbTypeText',
    width: 200,
  },
  {
    title: 'Host',
    dataIndex: 'host',
    width: 200,
  },
  {
    title: 'Port',
    dataIndex: 'port',
    width: 100,
  },
  {
    title: '用户名',
    dataIndex: 'username',
    width: 100,
  },
  {
    title: '包名',
    dataIndex: 'packageName',
    width: 200,
  },
  {
    title: '作者名',
    dataIndex: 'author',
    width: 120,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '数据源名称',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'dbType',
    label: '数据库类型',
    component: 'JDictSelectTag',
    colProps: { span: 8 },
    componentProps: () => {
      return {
        dictCode: 'database_type',
      };
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'id',
    component: 'Input',
    show: false,
  },
  // {
  //   field: 'code',
  //   label: '数据源编码',
  //   component: 'Input',
  //   required: true,
  //   dynamicDisabled: ({ values }) => {
  //     return !!values.id;
  //   },
  // },
  {
    field: 'name',
    label: '数据源名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'dbType',
    label: '数据库类型',
    component: 'JDictSelectTag',
    required: true,
    componentProps: ({ formModel }) => {
      return {
        dictCode: 'database_type',
        onChange: (e: any) => {
          // formModel = Object.assign(formModel, dbDriverMap[e], dbUrlMap[e]);
        },
      };
    },
  },
  // {
  //   field: 'dbDriver',
  //   label: '驱动类',
  //   required: true,
  //   component: 'Input',
  // },
  // {
  //   field: 'dbUrl',
  //   label: '数据源地址',
  //   required: true,
  //   component: 'Input',
  // },
  {
    field: 'host',
    label: 'Host',
    required: true,
    component: 'Input',
  },
  {
    field: 'port',
    label: 'Port',
    required: true,
    component: 'Input',
  },
  {
    field: 'dbName',
    label: '数据库',
    required: true,
    component: 'Input',
  },
  {
    field: 'username',
    label: '用户名',
    required: true,
    component: 'Input',
  },
  {
    field: 'password',
    label: '密码',
    required: true,
    component: 'InputPassword',
    slot: 'pwd',
  },
  {
    field: 'packageName',
    label: '包名',
    required: false,
    component: 'Input',
  },
  {
    field: 'delPrefix',
    helpMessage: "表名sys_user删除前缀sys_对应bean为User）多前缀逗号隔开",
    label: '删除前缀',
    required: false,
    component: 'Input',
  },
  {
    field: 'author',
    label: '作者名',
    required: false,
    component: 'Input',
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
  },
];
